<?php
/*******************************************************************************
 *
 *  Name: Analyst Model
 *
 *  Date: 4/3/2012
 *  
 *  Description: This model allows for access to entries within the Analyst 
 *               table in our database.
 *  
 *  Author: Hayden Waisanen
 *  
 *  Todo:
 *     NONE
 *
 *  Modification History:  
 * 
 *   Date         Name
 *  ----------   --------------
 *  2012-04-25   HAYDEN WAISANEN
 *  2012-04-17   HAYDEN WAISANEN
 *  2012-04-09   HAYDEN WAISANEN
 * 
 *****************************************************************************/
?>
<?php
class Analyst_model extends CI_Model {

    var $UserID = '';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
        $this->load->database();
    }
    
    function get($UserID)
    {
        $query = $this->db->get_where('Analyst', array('UserID' => $UserID));
        return $query->result_array();
    }
    function getAll()
    {
       $query = $this->db->get('Analyst');
       return $query->result_array();
    }

    function insert($fields)
    {
        //Check if it already exists
        $query = $this->db->get_where('Analyst', array('UserID' => $fields['UserID']));
        if( $query->num_rows() > 0 )
           return false;

        $this->UserID   = $fields['UserID'];

        $this->db->insert('Analyst', $this);
        return true;
    }

    //This function is useless because CR doesn't have any data
    function update($fields)
    {
        $this->UserID   = $fields['UserID'];
        $this->db->update('Analyst', $this, array('UserID' => $fields['UserID']));
    }
    function delete($UserID)
    {
         $this->db->where('UserID', $UserID);
         $this->db->delete('Analyst'); 
    }
}
?>
